package io.github.wanggit.antrpc.console.configuration;

import io.github.wanggit.antrpc.console.service.AccountService;
import io.github.wanggit.antrpc.console.web.filter.AuthFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebConfiguration {

    @Autowired private AccountService accountService;

    @Bean
    public FilterRegistrationBean<AuthFilter> testFilterRegistration() {
        FilterRegistrationBean<AuthFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new AuthFilter(accountService));
        registration.addUrlPatterns("/*");
        registration.setName(AuthFilter.class.getName());
        registration.setOrder(0);
        return registration;
    }
}
